package com.tiger.bmpeb.sample65;

import java.rmi.RemoteException;

import javax.ejb.FinderException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

public class Client2 {

	public static void main(String[] args) {
		try {
			InitialContext ctx = new InitialContext();
			Object obj = ctx.lookup("comp/env/ejb/CustomerBean04");
			CustomerHome04 customerHome = (CustomerHome04) PortableRemoteObject.narrow(obj, CustomerHome04.class);
			CustomerID customerID = new CustomerID(1);
			Customer04 customer = customerHome.findByPrimaryKey(customerID);
			System.out.println("name = " + customer.getName());
			System.out.println("age = " + customer.getAge());
		} catch (NamingException e) {
			e.printStackTrace();
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (FinderException e) {
			e.printStackTrace();
		}
	}

}
